package com.gdones.gpt.bus.modes.controller;


import com.gdones.common.core.annotations.MySysLog;
import com.gdones.common.core.annotations.MySysLogOpration;
import com.gdones.common.core.dto.MyPageBand;
import com.gdones.common.core.dto.MyResult;
import com.gdones.gpt.bus.modes.dto.GptModes;
import com.gdones.gpt.bus.modes.service.IGptModesService;
import com.gdones.gpt.bus.webAccount.dto.GptWebaccount;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  AI模型管理
 * </p>
 *
 * @author GaoJingBo
 * @since 2023-06-01
 */
@RestController
@RequestMapping("/modes")
@Slf4j
@Api(tags = "AI模型管理")
public class GptModesController {

    @Resource(name = "gptModesServiceImpl")
    private IGptModesService modesServiceImpl;

    @GetMapping("/pages")
    @ApiOperation("AI模型管理-分页")
    @MySysLog(modelName="AI模型管理",methodDesc = "分页",methodType = MySysLogOpration.GET)
    public MyResult pages(GptModes dto, MyPageBand pageBand){

        log.debug("--AI模型管理：分页");
        MyResult result = new MyResult();

        try {
            result = modesServiceImpl.pages(dto,pageBand);
        }catch (Exception e){
            e.printStackTrace();
            result.setCode("9999");
            result.setMsg("AI模型管理-分页-异常");
        }
        return result;
    }

    @GetMapping("/list")
    @ApiOperation("AI模型管理-列表不分页")
    @MySysLog(modelName="AI模型管理",methodDesc = "列表不分页",methodType = MySysLogOpration.GET)
    public MyResult list(GptModes dto ){

        log.debug("--AI模型管理：列表不分页");
        MyResult result = new MyResult();

        try {
            result = modesServiceImpl.mylist(dto);
        }catch (Exception e){
            e.printStackTrace();
            result.setCode("9999");
            result.setMsg("AI模型管理-列表不分页-异常");
        }
        return result;
    }

    @GetMapping("/getByID")
    @ApiOperation("AI模型管理-查询模型详情")
    @MySysLog(modelName="AI模型管理",methodDesc = "查询模型详情",methodType = MySysLogOpration.GET)
    public MyResult getByID(String id){

        log.debug("--AI模型管理：查询模型详情");
        MyResult result = new MyResult();

        try {
            result = modesServiceImpl.getByID(id);
        }catch (Exception e){
            e.printStackTrace();
            result.setCode("9999");
            result.setMsg("AI模型管理-查询模型详情-异常");
        }
        return result;
    }

    @PostMapping("/add")
    @ApiOperation("AI模型管理-添加")
    @MySysLog(modelName="AI模型管理",methodDesc = "添加",methodType = MySysLogOpration.POST)
    public MyResult add(@RequestBody GptModes dto){

        log.debug("--AI模型管理：添加");
        MyResult result = new MyResult();

        try {
            result = modesServiceImpl.add(dto);
        }catch (Exception e){
            e.printStackTrace();
            result.setCode("9999");
            result.setMsg("AI模型管理-添加-异常");
        }
        return result;
    }

    @PutMapping("/update")
    @ApiOperation("AI模型管理-修改")
    @MySysLog(modelName="AI模型管理",methodDesc = "修改",methodType = MySysLogOpration.PUT)
    public MyResult update(@RequestBody GptModes dto){

        log.debug("--AI模型管理：修改");
        MyResult result = new MyResult();

        try {
            result = modesServiceImpl.update(dto);
        }catch (Exception e){
            e.printStackTrace();
            result.setCode("9999");
            result.setMsg("AI模型管理-修改-异常");
        }
        return result;
    }

    @DeleteMapping("/deletes")
    @ApiOperation("AI模型管理-删除")
    @MySysLog(modelName="AI模型管理",methodDesc = "删除",methodType = MySysLogOpration.DELETE)
    public MyResult deletes(String ids){

        log.debug("--AI模型管理：删除");
        MyResult result = new MyResult();

        try {
            result = modesServiceImpl.deletes(ids);
        }catch (Exception e){
            e.printStackTrace();
            result.setCode("9999");
            result.setMsg("AI模型管理-删除-异常");
        }
        return result;
    }

}
